realmcrafterfandomcom-20200216-history
Death Loot Script
Created by Taz. Using "RC_Core.rcm" ; Age of Division ; Date/Time: 10:24:35 PM on 11/21/2010 ; By Naddaz on TAZCO ;executed from the death script, will couse player that dies to lose the items. ;Nov 1 2012 dTrying to add a chest that will spawn and hold all the items for a player when they die, the player will have a time amount to get to it before it becomes avalible to everyone. ;Death Chest is the name in the editor. Function Main() Player = Actor() PlayerZone$ = ActorZone(Player) HumPlayer% = ActorIsHuman(Player) PlayerZoneInc% = ActorZoneInstance(Player) PlayerZone$ = ActorZone(Player) Pname$ = Name(Player) ChestTag$ = + Pname + "s Death Chest" ;Player Cords PlayX# = ActorX(Player) PlayY# = ActorY(Player) + 5 PlayZ# = ActorZ(Player) ;give player there portable trainer back if they lost it. HasPT% = Hasitem(Player, "Info Guide") If (HasPT = 0) GiveItem(Player, "Info Guide") EndIf ScriptLog("Death loot script running by " + Pname) ChestActorID% = ActorID("Death Chest", "") ;Spawn Chest to hold players items. ChestActor$ = Spawn(ChestActorID, PlayerZone, PlayX, PlayY, PlayZ, "Death_Chest_RightClick", "", PlayerZoneInc) ;add a right click script. ;Set Player name to spawned chest and set loot to 1 for only player that spawned it can pick it up till time runs out. SetActorGlobal(ChestActor, 1, Pname) SetActorGlobal(ChestActor, 2, 1) ;1 = only player can open it, 5 means anyone can open it. SetTag(ChestActor, ChestTag) ;set chest tag to players name If (HumPlayer = 1) ; if player is human run the script. Slotamount% = 1 Repeat ;Spawn items alittle ways from player body. Adding a random 1 to 5 so all items will not be ontop of each other. RanX% = Rnd(1, 3) ;Random spawn place RanY% = Rnd(1, 3) ;Random spawn place RanZ% = Rnd(1, 3) ;Random spawn place ;spawn locations for items. ItemX = ActorX(Player) + RanX ItemY = ActorY(Player) + RanY ItemZ = ActorZ(Player) + RanZ Itemslot$ = ActorBackPack(Player, Slotamount) InvoName$ = ItemName(Itemslot) ;Exception itemsthat will not drop If (InvoName = "Info Guide") InvoName$ = "" EndIf If (InvoName = "Starter Sword") InvoName$ = "" EndIf If (InvoName = "Starter Staff") InvoName$ = "" EndIf If (InvoName = "Bow") InvoName$ = "" EndIf If (InvoName = "") ;Player has no item in slot do display anything. Else OutPut(Player, "You have lost " + InvoName, 145, 34, 24) ; SpawnItem(InvoName, 1, PlayerZone, ItemX, ItemY, ItemZ) ;spawn item from players invo slot 7 GiveItem(Player, InvoName, - 1) ;Take item from player on death ;Give Item to chest GiveItem(ChestActor, InvoName) ;Take item from player on death EndIf ;------------------------------- Slotamount% = Slotamount + 1 DoEvents(30) Until (Slotamount = 36) ;amount of slots to count, 32 for invo and 6 for gear. DoEvents(1000) ;------------------------------------------------------------------------------------- ;Run repeat until death chest goes public. TimeTilPublic% = 300 ;change to 5 min = 300 Repeat TimeTilPublic% = TimeTilPublic - 1 DoEvents(1000) IsOnline% = PlayerInGame(Player) If (IsOnline = 0) TimeTilPublic% = 0 Endif Until (TimeTilPublic <= 0) SetActorGlobal(ChestActor, 2, 5) ;1 = only player can open it, 5 means anyone can open it. ;Chest is public get rid of it, if it has not been looted in 5 mins TimeTilRemove% = 300 ;change to 5 min = 300 Repeat TimeTilRemove% = TimeTilRemove - 1 DoEvents(1000) Until (TimeTilRemove <= 0) SetAttribute(ChestActor, "Health", 0) ;kill spawned scripts. Return EndIf End Function